package robot.logging;

/**
 * @author David Ford
 * CS 424
 * ORANGS
 * 
 * This is the logging module for the ORANGS program.
 *
 */

import java.util.*;
import java.io.*;
import java.text.*;

import robot.*;


public class Logging{
	// private variables below...
	// 3D coordinate variables
	// forward and reverse kinematics info
		
	
	
	public void writeLog(){
		Date currentTime = new Date();	// the current date and time when file is created
		SimpleDateFormat fName = new SimpleDateFormat("'Log' MM-dd-yyyy km sS'.txt'");	// formatted file name based on the time
		
		// upon commit/start from program,new log is generated 
		try {
			// create the log
			File dir = new File("robot/logging/logs");
			dir.mkdirs();
			File f = new File(dir, fName.format(currentTime));
			
			if (f.exists()){
				System.err.println("Error - log exists already.");
			}
			else {
				FileWriter fw = new FileWriter(f);			
				SimpleDateFormat fDate = new SimpleDateFormat("hh:mm:ss, E. MMM dd, yyyy");
				BufferedWriter output = new BufferedWriter(fw);
				output.write("------- " + fDate.format(currentTime) + " --------\n\n");
				output.write("Hello there.\n\n");
				output.close();		// close the writer, save the file
			}
		}
		catch (Exception e){
			System.err.println("Error: " + e.getMessage());
		}
			
	}


	public static void main(String[] args){
			Logging test = new Logging();
			test.writeLog();
	}
}